# apps/light_theme/light_theme/overrides/__init__.py
def after_migrate_hook():
    """安全的迁移后钩子"""
    try:
        from light_theme.utils import get_loader_config
        if get_loader_config().get("enable_loader"):
            return inject_loader()
    except:
        pass
    return ""

def inject_loader():
    """实际注入逻辑"""
    return """
    <script>
    if(!window._loader_injected){
        const loader = document.createElement('div');
        loader.id = 'global-loader';
        loader.className = 'light-theme-loader';
        loader.innerHTML = `
            <div class="loader-container">
                <div class="frappe-logo-spinner"></div>
                <div class="progress-bar"></div>
            </div>
        `;
        document.body.appendChild(loader);
        window._loader_injected = true;
    }
    </script>
    """